<html>
<head>
<title>(S,P,O)</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://www.datatables.net/release-datatables/media/css/demo_page.css" type="text/css" media="screen" />
<link rel="stylesheet" href="http://www.datatables.net/release-datatables/media/css/demo_table.css" type="text/css" media="screen" />
<link rel="stylesheet" href="http://dev.iceburg.net/jquery/jqModal/jqModal.css" type="text/css" media="screen" />
<script type="text/javascript" language="javascript" src="http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="http://dev.iceburg.net/jquery/jqModal/jqModal.js"></script>
<script type="text/javascript">
window.onload = function() {
	$('#dialog').jqm(); 
	$('#about').click(showAbout);
	var inputUrl = gup('inputUrl');
	if (inputUrl) { 
		$('#inputUrl').val(unescape(inputUrl));
		$("td").live("mouseover",showlink);
		update(inputUrl) 
	} else { 
		showAbout()
	};
};
showAbout = function () {
		$('#dialog').jqmShow(); 
		$('#showCode').click( function() { $('#code').show(); return false });
		return false;
}
update = function (inputUrl) {
	var url = 'http://pipes.yahoo.com/pipes/pipe.run?' +
		'_id=ba4b7c565feb2842f00914ea38f5e007&' + 
		'url=' + inputUrl + '&_render=json&_callback=?';
	$.getJSON(url,function(data) {
		$(data.value.items).each(function(index,item) {
			var item_html = '<tr><td>' + item.subject.value + '</td>' + 
				'<td>' + item.predicate.value + '</td>' + 
				'<td>' + prtObject(item.object) + '</td></tr>';
			$('#table_body').append(item_html);
		});
		$("#example").dataTable();
	});
}
prtObject = function (object) {
	var str;
	if (object.type == 'literal') {
		str = '"' + object.value + '"';
		if (object.datatype) {
			str += '^^' + object.datatype;
		}
		if (object.lang) {
			str += '@' + object.lang;
		}
	} else {
		str = object.value;
	}
	return str;
}
showlink = function () {
	var text = $(this).text();
	if (text.toLowerCase().indexOf("http://") == 0) {
		$(this).addClass('link');
		$("td").click(function(){ window.location.replace('spo.html?inputUrl=' + text) });
	}
}
gup = function (name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}
</script>
<style>
table {
	font-size: 10px;
}
.link {
	cursor: hand;
	cursor: pointer;
}
</style>
</head>
<body id="dt_example">
	<div style='margin:0 auto 0 auto;width:800px'>
	<div style='background-color:#F85931'>
	<br />
	<form action="spo.html" method="get">
		&nbsp;RDF URL: <input type="text" name="inputUrl" size="60" id="inputUrl" /> 
		<input type="submit" value="Submit" />
		<button id='about'>About</button>
	</form>
	<hr />
	</div>
	<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
		<thead><tr><th>Subject</th><th>Predicate</th><th>Object</th></tr></thead>
		<tbody id="table_body"></tbody>
	</table>
	</div>

	<div class="jqmWindow" id="dialog">
		<a href="#" class="jqmClose">Close</a><hr />
		Simple <a href="http://triplr.com">triplr</a> / <a href="http://pipe.yahoo.com">yahoo pipe</a> ajax call.
		<a href='#' id='showCode'>show code</a><br />
		<textarea style='width: 600px; height: 200px;display:none' id='code'>
  var url = 'http://pipes.yahoo.com/pipes/pipe.run?' +
    '_id=ba4b7c565feb2842f00914ea38f5e007&' +
    'url=' + inputUrl + '&_render=json&_callback=?';

  $.getJSON(url,function(data) {
    $(data.value.items).each(function(index,item) {

      $('#table_body').append(
        '<tr><td>' + item.subject.value + '</td>' +
        '<td>' + item.predicate.value + '</td>' +
        '<td>' + prtObject(item.object) + '</td></tr>';
      )

    });
  });

		</textarea>

		<br /><br />

		Implemented on top of:

			<li><a href="http://triplr.com">triplr</a></li>
			<li><a href="http://pipe.yahoo.com">yahoo pipe</a></li>
			<li><a href="http://jquery.com/">jquery</a></li>
			<li><a href="http://www.datatables.net/">datatables</a></li>
			<li><a href="http://dev.iceburg.net/jquery/jqModal/">jqmodal</a></li>


		<br /><br />

		Samples:
			<li><a href="spo.html?inputUrl=http%3A%2F%2Fdbpedia.org%2Fdata%2FUniversity_of_Chile.rdf">Universidad de Chile</a></li>
			<li><a href="spo.html?inputUrl=http%3A%2F%2Fdbpedia.org%2Fdata%2FRadio_Cooperativa.rdf">Radio Cooperativa</a></li>
			<li><a href="spo.html?inputUrl=http%3A%2F%2Fdbpedia.org%2Fdata%2FTV_Chile.rdf">TV Chile</a></li>
			<li><a href="spo.html?inputUrl=http%3A%2F%2Fbblfish.net%2Fwork%2Fatom-owl%2F2006-06-06%2Fexamples%2Fbblfish.atom.ttl">turtle atom</a></li>
			<li><a href="spo.html?inputUrl=http://sws.geonames.org/6254976/nearby.rdf">geonames</a></li>
	</div>

</body>
</html>

